﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SpecialEffects
{
    /// <summary>
    /// This class struct represents a vertex of a particle effect for fire and smoke.
    /// </summary>
    public struct ParticleVertex
    {
        /// <summary>
        /// Start position of a particle effect.
        /// </summary>
        public Vector3 startPos
        {
            get;
            set;
        }

        /// <summary>
        /// Texture coordinates.
        /// </summary>
        public Vector2 uv
        {
            get;
            set;
        }

        /// <summary>
        /// Moving direction of a particle.
        /// </summary>
        public Vector3 direction
        {
            get;
            set;
        }

        /// <summary>
        /// Moving speed of a particle.
        /// </summary>
        public float speed
        {
            get;
            set;
        }

        /// <summary>
        /// The time when this particle effect was created.
        /// </summary>
        public float birthTime
        {
            get;
            set;
        }

        /// <summary>
        /// The constructor of this class struct.
        /// </summary>
        public ParticleVertex(Vector3 startPosition, Vector2 uv, Vector3 direction, float speed, float birthTime) : this()
        {
            this.startPos = startPosition;
            this.uv = uv;
            this.direction = direction;
            this.speed = speed;
            this.birthTime = birthTime;
        }

        /// <summary>
        /// The vertexdeclaration for the graphicsdevice. Contains information of this vertex.
        /// </summary>
        public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
            (new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
             new VertexElement(sizeof(float) * 3, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
             new VertexElement(sizeof(float) * (3 + 2), VertexElementFormat.Vector3, VertexElementUsage.TextureCoordinate, 1),
             new VertexElement(sizeof(float) * (3 + 2 + 3), VertexElementFormat.Single, VertexElementUsage.TextureCoordinate, 2),
             new VertexElement(sizeof(float) * (3 + 2 + 3 + 1), VertexElementFormat.Single, VertexElementUsage.TextureCoordinate, 3));

    }
}

